package com.example.ollamatest2.controller;

import com.example.ollamatest2.result.Result;
import com.example.ollamatest2.result.ResultCodeEnum;
import com.example.ollamatest2.result.ResultUtil;
import com.example.ollamatest2.vo.QuestionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.example.ollamatest2.unit.HttpClientTest.stringJson;
import static com.example.ollamatest2.unit.HttpClientTest.testPOST;

@RestController
@RequestMapping("/useToRoode")
@Api(tags = {"道路测试"})
public class ModController {
    @SneakyThrows
    @ApiOperation("模型询问")
    @PostMapping("/roodUse")
    public Result addSubject(@RequestBody QuestionVo questionVo){
        String message = "yes";
                //testPOST("llava", questionVo.getQuestionA() +",你只需要告诉我yes或no一个词语即可。",questionVo.getBase64());

        //stringJson(message);
        if (questionVo.getQuestionB().equals("")){
            return ResultUtil.success(ResultCodeEnum.SUCCESS,message);
        }
        else if (message.contains("Yes")||message.contains("yes")) {
            String message2 = "123";
            //testPOST("llava", questionVo.getQuestionB(), questionVo.getBase64());
            //message2 = stringJson(message2);
            return ResultUtil.success(ResultCodeEnum.SUCCESS,message2);
        } else {
            return ResultUtil.success(ResultCodeEnum.SUCCESS,"抱歉,该图片不符合要求");
        }
    }
}
